package com.chixing.day10.day10_Homew;

public class JobTest {
    public static void main(String[] args) throws OutBoundException {
        Company c1 = new Company(101,"珠海市魅族科技有限公司","民营公司","（计算机，通信，网络设备）");
        Company c2 = new Company(102,"慧博云通科技股份有限公司","民营公司","（软件，大数据）");
        Company c3=new Company(103,"中国移动","国企公司","（计算机，系统，数据服务，维修）");

        Job[] jobs1 = c1.sendJob();
        jobs1[0].setJobId(901);
        jobs1[0].setJobName("Java开发工程师");
        jobs1[0].setCompany(c1);
        jobs1[0].setMinSalary(5000);
        jobs1[0].setMaxSalary(8000);
        jobs1[0].setJobAddress("南京");
        jobs1[0].setJobDegree("本科学历");
        c1.sendJob();
        jobs1[1].setJobId(902);
        jobs1[1].setJobName("系统开发工程师");
        jobs1[1].setCompany(c1);
        jobs1[1].setMinSalary(4000);
        jobs1[1].setMaxSalary(9000);
        jobs1[1].setJobAddress("无锡");
        jobs1[1].setJobDegree("本科学历");

        Job[] jobs2 = c2.sendJob();
        jobs2[0].setJobId(903);
        jobs2[0].setJobName("运维工程师");
        jobs2[0].setCompany(c2);
        jobs2[0].setMinSalary(3000);
        jobs2[0].setMaxSalary(5000);
        jobs2[0].setJobAddress("上海");
        jobs2[0].setJobDegree("本科学历");
        c2.sendJob();
        jobs2[1].setJobId(904);
        jobs2[1].setJobName("实施工程师");
        jobs2[1].setCompany(c2);
        jobs2[1].setMinSalary(6000);
        jobs2[1].setMaxSalary(8000);
        jobs2[1].setJobAddress("上海");
        jobs2[1].setJobDegree("本科学历");

        Job[] jobs3 = c3.sendJob();
        jobs3[0].setJobId(905);
        jobs3[0].setJobName("Java开发工程师");
        jobs3[0].setCompany(c3);
        jobs3[0].setMinSalary(7000);
        jobs3[0].setMaxSalary(10000);
        jobs3[0].setJobAddress("南京");
        jobs3[0].setJobDegree("本科学历");
        countNumber(c2);
        Company[] companies = {c1,c2,c3};
        Company[] companies1 = ifCptCom(companies);
        for (int i = 0; i < companies1.length; i++) {
            System.out.println(companies1[i]);
        }
    }
    public static void countNumber(Company company){
        for (int i = 0; i < company.getCount(); i++) {
            int count = 0;
            for (int j = 0; j < company.getCount(); j++) {
                if(company.getJobs()[i].getJobAddress() == company.getJobs()[j].getJobAddress()){
                    count++;
                }
            }
            System.out.println(company.getCompName()+ "在" + company.getJobs()[i].getJobAddress() + "发布的职位数为：" + count);
        }
    }
    public static Company[] ifCptCom(Company[] company){
        for (int i = 0; i <company.length ; i++) {
            if (!(company[i].getComFlag().contains("计算机"))) {
                company[i] = null;
            }
        }
        return company;
    }

}
